import { createApp } from 'vue';
import './style.css';
import App from './App.vue';
import { I18n, createI18n } from 'vue-i18n';
import { setupRouter } from './router/index.js';
// 请求和loading的配置
import '@/global/js/request';
import ElementPlus from 'element-plus';
import zhLocale from 'element-plus/es/locale/lang/zh-cn';
import 'element-plus/theme-chalk/index.css';
// 启用element-plus的暗黑模式
import 'element-plus/theme-chalk/dark/css-vars.css';
import '@sutpc/pingshan-omp-base/styles/index.less';


import registerComponents from '@/global/js/components';

import '@purge-icons/generated';
import 'virtual:svg-icons-register';
import 'virtual:windi.css';
import dayjs from 'dayjs';
import { dayjs as elDayjs } from 'element-plus';
import zhcn from 'dayjs/locale/zh-cn';
import pinia from './store/index';

dayjs.locale(zhcn);
// 构建后，element-plus是script引入，它里面也有打包一个dayjs
// 需要给这个dayjs也设置中文，否则可能出现日期格式化显示英文的情况
elDayjs.locale(zhcn);

const app = createApp(App);
const i18n = createI18n({
  legacy: false,
  locale: sessionStorage.getItem('locale') || 'zh-CN',
  fallbackLocale: 'zh-CN',
  messages: {
    ['zh-CN']: {},
    ['en-US']: {}
  },
  availableLocales: ['zh-CN', 'en-US'],
  sync: true,
  silentTranslationWarn: true,
  missingWarn: false,
  silentFallbackWarn: true
}) as I18n;
app.use(i18n);
app.use(pinia);
app.use(ElementPlus, {
  locale: zhLocale
});
registerComponents(app);

setupRouter(app);

app.mount('#app');
